package com.dailyblue.java.spring.boot.jwt.test;

import com.dailyblue.java.spring.boot.jwt.BootJWTLoginApplication;
import com.dailyblue.java.spring.boot.jwt.bean.User;
import com.dailyblue.java.spring.boot.jwt.util.JwtConfig;
import io.jsonwebtoken.Claims;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = BootJWTLoginApplication.class)
@Slf4j
public class App {
    @Test
    public void a(){
        User user = new User();
        user.setId(1);
        user.setNickname("张三");
        String jwt = JwtConfig.getJwtToken(user);
        log.info("{}",jwt);
    }
    @Test
    public void b(){
        String str = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkYWlseWJsdWUiLCJpYXQiOjE2Njg4MjIyODgsImV4cCI6MTY2ODkwODY4OCwiaWQiOjEsIm5hbWUiOiLlvKDkuIkifQ.ORnm-MMRH84EuNMx9zPrHRkvwKbApMMVhosj4O39YZU";
        boolean b = JwtConfig.checkToken(str);
        Claims claims = JwtConfig.parseJWT(str);
        log.info("是否存在:{},内容是:{}",b,claims);
    }
}
